package br.com.dev.tcc.view.apolice;

import java.util.List;

import android.os.Bundle;
import br.com.dev.tcc.R;
import br.com.dev.tcc.bean.Apolice;
import br.com.dev.tcc.model.ListaPreferenciasModel;
import br.com.dev.tcc.view.DefaultSupportActionBarActivity;

public class PreferenciasActivity extends DefaultSupportActionBarActivity {

	private ListaPreferenciasModel model;
	private ListaPreferenciasView view;

	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.prefs);
		setActionBar(R.string.preferencias, R.string.pref_sub,
				R.drawable.preferencias);

		model = new ListaPreferenciasModel(this);
		view = new ListaPreferenciasView(this);
	}

	@Override
	protected void onResume() {

		super.onResume();

		setList();
	}

	private void setList() {

		List<Apolice> itens = model.getListApolices();

		if (itens.size() > 0) {

			view.setItens(itens);
		} 
		else {

			view.hideList();
		}
	}
}
